package com.gitee.magic.core.utils.codec;

/**
 * @author start
 */
public class Hex {

	/**
	 * 字节转十进制
	 */
	public static String byteToHex(byte b) {
		String hex = Integer.toHexString(b & 0xFF);
		int i=2;
		if (hex.length() < i) {
			hex = "0" + hex;
		}
		return hex;
	}

	/**
	 * 字节数组转十进制
	 */
	public static String bytesToHex(byte[] bytes) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < bytes.length; i++) {
			sb.append(byteToHex(bytes[i]));
		}
		return sb.toString();
	}

}
